package com.beiben.ability.people.domain;

import com.beiben.system.user.domain.BeiBenDeptUser;
import com.beiben.system.user.domain.BeiBenUser;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

public class TreeSelectDept implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    /** 用戶 */
    private List<BeiBenUser> users;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelectDept> depts;

    public TreeSelectDept(BeiBenDeptUser beiBenUser)
    {
        this.id = beiBenUser.getDeptId();
        this.label = beiBenUser.getDeptName();
        this.users = beiBenUser.getUsers();
        this.depts = beiBenUser.getDepts().stream().map(TreeSelectDept::new).collect(Collectors.toList());
    }


    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getLabel()
    {
        return label;
    }

    public void setLabel(String label)
    {
        this.label = label;
    }

    public List<TreeSelectDept> getDepts() {
        return depts;
    }

    public void setDepts(List<TreeSelectDept> depts) {
        this.depts = depts;
    }

    public List<BeiBenUser> getUsers() {
        return users;
    }

    public void setUsers(List<BeiBenUser> users) {
        this.users = users;
    }
}